﻿#include "stdafx.h"
#include "../../GameCore/CGame.h"

void CGame::RenderGamePlay()
{
	if (_GameSubState == k_LOOP || _GameSubState== k_DESTROY)
	{
		_g->SetColor(0xffffff);
		_g->FillRect(0, 0, k_SCREEN_WIDTH, k_SCREEN_HEIGHT);

		_g->SetColor(0xff0000);
		_g->DrawLine(0, 110, k_SCREEN_WIDTH, 110);
		_g->DrawLine(0, k_SCREEN_HEIGHT - 25, k_SCREEN_WIDTH, k_SCREEN_HEIGHT - 25);
	
		//render Animals
		RenderAnimals();

		//render Items
		RenderItems();

		//render basket
		RenderBasket();
	}
	
}

void CGame::UpdateGamePlay()
{
	if(_GameSubState==k_INIT)
	{		
		
		GET_CONFIG()._current_level = 0;
		_basket_posX = k_SCREEN_WIDTH/2 - 50;
		_basket_posY = k_SCREEN_HEIGHT - 110;
		GET_CONFIG()._current_charater_hp = 3;
		GET_CONFIG()._current_egg_count = 0;
		GET_CONFIG()._current_level = 0;
		_on_key_narrow_left = false;
		_on_key_narrow_right = false;
		ResetAnimals();
		ResetItems();
		SetSubState(k_FIRST_TIME);
	}
	else if(_GameSubState==k_FIRST_TIME)	
	{
		SetSubState(k_LOOP);
	}
	else if (_GameSubState == k_LOOP)
	{
		//update all animals
		UpdateAnimals();
		
		//update all items
		UpdateItems();

		//update basket
		UpdateBasket();
		
	}
	else if (_GameSubState == k_DESTROY)
	{
		SetGameState(_GameStateNew, false);
	}
}

void CGame::TouchGamePlay()
{
}
